<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>故障诊断系统</title>
    <link rel="shortcut icon" href="../static/img/favicon.ico">
    <link rel="stylesheet" href="../static/plugins/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="../static/plugins/font-awesome/css/font-awesome.min.css" media="all"/>
    <link rel="stylesheet" href="../static/src/css/app.css" media="all"/>
    <link rel="stylesheet" href="../static/src/css/message.css" media="all"/>
    <link rel="stylesheet" href="../static/src/css/nprogress.css" media="all"/>
    <link rel="stylesheet" href="../static/src/css/themes/default.css" media="all" id="skin" kit-skin/>
    <script src="../static/plugins/layui/layui.js"></script>
    <script src="../static/js/jquery-3.2.1.min.js"></script>
</head>

<body class="kit-theme">
<div class="layui-layout layui-layout-admin kit-layout-admin">
    <div class="layui-header">
        <div class="layui-logo" style="width: auto">高空作业车液压系统故障诊断系统</div>
        <ul class="layui-nav layui-layout-right kit-nav">
            <li class="layui-nav-item">
                <a href="javascript:;">
                    <i class="layui-icon">&#xe63f;</i> 皮肤
                </a>
                <dl class="layui-nav-child skin">
                    <dd><a href="javascript:;" data-skin="default" style="color:#393D49;"><i
                            class="layui-icon">&#xe658;</i> 默认</a></dd>
                    <dd><a href="javascript:;" data-skin="orange" style="color:#ff6700;"><i
                            class="layui-icon">&#xe658;</i> 橘子橙</a></dd>
                    <dd><a href="javascript:;" data-skin="green" style="color:#00a65a;"><i
                            class="layui-icon">&#xe658;</i> 原谅绿</a></dd>
                    <dd><a href="javascript:;" data-skin="pink" style="color:#FA6086;"><i
                            class="layui-icon">&#xe658;</i> 少女粉</a></dd>
                    <dd><a href="javascript:;" data-skin="blue.1" style="color:#00c0ef;"><i
                            class="layui-icon">&#xe658;</i> 天空蓝</a></dd>
                    <dd><a href="javascript:;" data-skin="red" style="color:#dd4b39;"><i class="layui-icon">&#xe658;</i>
                        枫叶红</a></dd>
                </dl>
            </li>
            <li class="layui-nav-item">
                <a href="javascript:;">
                    <img src="../static/img/0.jpg" class="layui-nav-img">
                    {{ user }}
                </a>
                <dl class="layui-nav-child">
                    <dd><a href="javascript:;" id="uppwd"><span>修改密码</span></a>
                    </dd>
                </dl>
            </li>
            <li class="layui-nav-item"><a href="/login_out/"><i class="fa fa-sign-out" aria-hidden="true"></i> 注销</a>
            </li>
        </ul>
    </div>

    <div class="layui-side layui-bg-black kit-side">
        <div class="layui-side-scroll">
            <div class="kit-side-fold"><i class="fa fa-navicon" aria-hidden="true"></i></div>
            <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
            <ul class="layui-nav layui-nav-tree" lay-filter="kitNavbar" kit-navbar>
                {% if request.session.identity %}
                    <li class="layui-nav-item">
                        <a href="javascript:;" data-url="/userlist/" data-name="user" data-title="用户管理" kit-target><i
                                class="layui-icon">&#xe613;</i><span> 用户管理</span></a>
                    </li>
                {% endif %}
                <li class="layui-nav-item">
                    <a href="javascript:;" data-url="/real_time/" data-title="实时监测" kit-target
                       data-id='0'><i class="layui-icon">&#xe62c;</i><span> 在线检测</span></a>
                </li>
                <li class="layui-nav-item">
                    <a class="" href="javascript:;"><i class="fa fa-plug"></i><span> 故障分析</span></a>
                    <dl class="layui-nav-child">
                        <dd>
                            <a href="javascript:;" kit-target
                               data-options="{url:'/fault/',title:'故障信息库',id:'1'}">
                                <i class="layui-icon">&#xe62d;</i><span> 信息库浏览</span></a>
                        </dd>
                        <dd>
                            <a href="javascript:;" data-url="/reason/" data-title="故障推理" kit-target
                               data-id='2'><i class='layui-icon'>&#xe642;</i><span> 故障推理</span></a>
                        </dd>
                    </dl>
                </li>
                <li class="layui-nav-item">
                    <a class="" href="javascript:;"><i class="layui-icon">&#xe60e;</i><span> 日志</span></a>
                    <dl class="layui-nav-child">
                        <dd>
                            <a href="javascript:;" kit-target
                               data-options="{url:'/fault_info/',title:'故障日志',id:'3'}">
                                <i class="layui-icon">&#xe628;</i><span> 故障日志</span></a>
                        </dd>
                        <dd>
                            <a href="javascript:;" data-url="/operate_info/" data-title="用户日志" kit-target
                               data-id='4'><i class='layui-icon'>&#xe621;</i><span> 用户日志</span></a>
                        </dd>
                    </dl>
                </li>

            </ul>
        </div>
    </div>
    <div class="layui-body" id="container">
        <!-- 内容主体区域 -->
        <div style="padding: 15px;"><i class="layui-icon layui-anim layui-anim-rotate layui-anim-loop">&#xe63e;</i>
            请稍等...
        </div>
    </div>
    <div class="layui-footer " style="height: 37px;font-size: 17px;">
        <div style="float: right">
            <!-- 底部固定区域 -->
            Copyright &copy;2018 高空作业车液压系统故障诊断系统 by
            <a href="#" style="color: #FF5722">赵新城</a>
        </div>
    </div>
</div>

</body>
<script>
    var message;
    layui.config({
        base: '../static/src/js/',
    }).use(['app', 'message'], function () {
        var app = layui.app,
            $ = layui.jquery,
            layer = layui.layer;
        //将message设置为全局以便子页面调用
        message = layui.message;
        //主入口
        app.set({
            type: 'iframe'
        }).init();
        $('dl.skin > dd').on('click', function () {
            var $that = $(this);
            var skin = $that.children('a').data('skin');
            switchSkin(skin);
        });
        var setSkin = function (value) {
                layui.data('kit_skin', {
                    key: 'skin',
                    value: value
                });
            },
            getSkinName = function () {
                return layui.data('kit_skin').skin;
            },
            switchSkin = function (value) {
                var _target = $('link[kit-skin]')[0];
                _target.href = _target.href.substring(0, _target.href.lastIndexOf('/') + 1) + value + _target.href.substring(_target.href.lastIndexOf('.'));
                setSkin(value);
            },
            initSkin = function () {
                var skin = getSkinName();
                switchSkin(skin === undefined ? 'default' : skin);
            }();
    });
</script>
<script>
    layui.use(['layer', 'form'], function () {
        var layer = layui.layer;
        $('#uppwd').on('click', function () {
            layer.open({
                type: 1,
                title: '修改密码',
                closeBtn: false,
                area: ['330px', '300px'],
                id: 'update_pwd', //设定一个id，防止重复弹出
                btn: ['确认', '取消'],
                btnAlign: 'r',
                offset: 'ct',
                anim: 1,
                moveType: 1,//拖拽模式，0或者1,
                content: ' <br><form class="layui-form layui-form-pane" action=""><input id="user_name" value="{{ user }}" style="display: none"/><div ' +
                'class="layui-form-item"><label class="layui-form-label">旧密码</label><div class="layui-input-inline">' +
                ' <input type="text" name="oldpass"  id="oldpass" lay-verify="required" placeholder="请输入旧密码" ' +
                'autocomplete="off" ' +
                'class="layui-input"></div></div><div class="layui-form-item">' +
                ' <label class="layui-form-label">新密码</label>' +
                ' <div class="layui-input-inline">' +
                ' <input type="text" name="newpass" id="newpass" lay-verify="required" placeholder="请输入新密码" ' +
                'autocomplete="off" class="layui-input">' +
                '</div></form> ',
                yes: function (index) {
                    if ($.trim($('#oldpass').val()) == '') {
                        layer.msg('请输入旧密码', {icon: 5});
                        return false
                    } else if ($.trim($('#newpass').val()) == '') {
                        layer.msg('请输入新密码', {icon: 5});
                        return false
                    } else if ($.trim($('#newpass').val()).length < 6) {
                        layer.msg('新密码至少6位', {icon: 5});
                        return false
                    }
                    layer.close(index)
                    $.ajax({
                        url: '/update_pass',
                        method: 'get',
                        data: 'oldpass=' + $.trim($('#oldpass').val()) + '&newpass=' + $.trim($('#newpass').val())
                        + '&username=' + $('#user_name').val(),
                        success: function (data) {
                            if (data == 1) {
                                layer.msg('修改成功，2秒后跳转登录界面', {icon: 1});
                                setTimeout('location.reload()', 2000)
                            } else if (data == 0) {
                                layer.msg('修改失败', {icon: 5});
                                return false
                            } else {
                                layer.msg('旧密码错误', {icon: 5});
                                return false
                            }
                        }
                    })
                }
            })
        })
    })

</script>
</html>